/**
 * SysUserDaoImpl.java
 * Created at 2016-12-26
 * Created by Tinel
 * Copyright (C) 2015 BROADTEXT SOFTWARE, All rights reserved.
 */
package com.broadtext.rms.system.dao.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.broadtext.common.exp.DaoException;
import com.broadtext.common.repository.EntityDao;
import com.broadtext.rms.system.dao.ISysUserDao;
import com.broadtext.rms.system.model.SysAccountValidity;
import com.broadtext.rms.system.model.SysUser;

/**
 * <p>
 * ClassName: ISysUserDao
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Author: shihui
 * </p>
 * <p>
 * Date: 2016-12-26
 * </p>
 */
@Repository("sysUserDao")
public class SysUserDaoImpl extends EntityDao<SysUser> implements ISysUserDao {

    /**
     * 
     * <p>Description: 根据用户名获取用户信息</p>
     * @param userName 用户名
     * @return List<SysUser>
     * @throws DaoException daoException
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<SysUser> selectByUserName(String userName) throws DaoException {
        List<SysUser> list;
        list = new ArrayList<SysUser>();
        list = super.findByProperty("com.broadtext.rms.system.model.SysUser.findEntityByUserName", userName);
        return list;
    }

    /**
     * 
     * <p>Description: 修改用户密码</p>
     * @param user 用户实体
     * @return 修改结果
     * @throws DaoException 异常
     */
    @Override
    public boolean modityUserPass(SysUser user) throws DaoException {
        user.setUpdateUser(user.getLoginName());
        user.setUpdateDate(new Date());
        return this.updateRecord("com.broadtext.rms.system.model.SysUser.updateRecord", user);
    }

    /**
     * 
     * <p>Description: 查询账户使用期限</p>
     * @param loginName 用户名
     * @return List<SysAccountValidity>
     * @throws DaoException 异常
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<SysAccountValidity> getAccountValidity(String loginName) throws DaoException {
        List<SysAccountValidity> list;
        list = new ArrayList<SysAccountValidity>();
        list = super.findByProperty("com.broadtext.rms.system.model.VSysUsers.findAccountByloginName", loginName);
        return list;
    }
}
